<template>
    <div>
        <Modal v-model="modal.add" title="添加" :mask-closable="false" @on-visible-change="changeModalVisibleResetForm('addForm', $event)" width="760">
            <Form ref="addForm" :model="form" :label-width="80" :rules="validateRules">
                <Row>
	<i-col span="12">
	<FormItem label="作业名称" prop="name">
	<Input v-model="form.name" placeholder="请输入作业名称" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="完整类名" prop="className">
	<Input v-model="form.className" placeholder="请输入完整类名" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="cron表达式" prop="cronExpression">
	<Input v-model="form.cronExpression" placeholder="请输入cron表达式" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="作业组名称" prop="groupName">
	<Input v-model="form.groupName" placeholder="请输入作业组名称" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="触发器名称" prop="triggerName">
	<Input v-model="form.triggerName" placeholder="请输入触发器名称" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="触发器组" prop="triggerGroup">
	<Input v-model="form.triggerGroup" placeholder="请输入触发器组" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="作业描述" prop="description">
	<Input v-model="form.description" placeholder="请输入作业描述" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="作业状态" prop="jobStatus">
	<InputNumber v-model="form.jobStatus" placeholder="请输入作业状态" style="width: 100%;"/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="状态更新时间" prop="jobStatusTime">
	<DatePicker @on-change="form.jobStatusTime=$event" :value="form.jobStatusTime" placeholder="请输入状态更新时间" type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 100%;" clearable></DatePicker>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="自动启动" prop="autoStart">
	<InputNumber v-model="form.autoStart" placeholder="请输入自动启动" style="width: 100%;"/>
</FormItem>
	</i-col>
</Row>

            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="resetFormCancelModal('addForm', 'add')">取消</Button>
                <Button type="primary" size="large" @click="add" :loading="loading.add">添加</Button>
            </div>
        </Modal>
        <Modal v-model="modal.edit" title="修改" :mask-closable="false" @on-visible-change="changeModalVisibleResetForm('editForm', $event)" width="760">
            <Form ref="editForm" :model="form" :label-width="80" :rules="validateRules">
                <Row>
	<i-col span="12">
	<FormItem label="作业名称" prop="name">
	<Input v-model="form.name" placeholder="请输入作业名称" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="完整类名" prop="className">
	<Input v-model="form.className" placeholder="请输入完整类名" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="cron表达式" prop="cronExpression">
	<Input v-model="form.cronExpression" placeholder="请输入cron表达式" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="作业组名称" prop="groupName">
	<Input v-model="form.groupName" placeholder="请输入作业组名称" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="触发器名称" prop="triggerName">
	<Input v-model="form.triggerName" placeholder="请输入触发器名称" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="触发器组" prop="triggerGroup">
	<Input v-model="form.triggerGroup" placeholder="请输入触发器组" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="作业描述" prop="description">
	<Input v-model="form.description" placeholder="请输入作业描述" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="作业状态" prop="jobStatus">
	<InputNumber v-model="form.jobStatus" placeholder="请输入作业状态" style="width: 100%;"/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="状态更新时间" prop="jobStatusTime">
	<DatePicker @on-change="form.jobStatusTime=$event" :value="form.jobStatusTime" placeholder="请输入状态更新时间" type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 100%;" clearable></DatePicker>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="自动启动" prop="autoStart">
	<InputNumber v-model="form.autoStart" placeholder="请输入自动启动" style="width: 100%;"/>
</FormItem>
	</i-col>
</Row>

            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="resetFormCancelModal('editForm', 'edit')">取消</Button>
                <Button type="primary" size="large" @click="edit" :loading="loading.edit">修改</Button>
            </div>
        </Modal>
    </div>
</template>

<script>
    export default {
        name: 'SchedulerAddEdit',
        data() {
            return {
                modal: {
                    add: false,
                    edit: false
                },
                loading: {
                    add: false,
                    edit: false
                },
                urls: {
                    addUrl: '/scheduler/admin/save',
                    batchAddUrl: '/scheduler/admin/batch-save',
                    editUrl: '/scheduler/admin/update',
                    batchEditUrl: '/scheduler/admin/batch-update'
                },
                form: {
                    id: null,
name: null,
className: null,
cronExpression: null,
groupName: null,
triggerName: null,
triggerGroup: null,
description: null,
jobStatus: null,
jobStatusTime: null,
autoStart: null,


                },
                validateRules: {
                    name: [
{type: 'string', required: true, message: '此项为必须项', trigger: 'blur'},
{type: 'string', min: 1, max: 50, message: '必须1-50个字符', trigger: 'blur'}
],
className: [
{type: 'string', required: true, message: '此项为必须项', trigger: 'blur'},
{type: 'string', min: 1, max: 200, message: '必须1-200个字符', trigger: 'blur'}
],
cronExpression: [
{type: 'string', required: true, message: '此项为必须项', trigger: 'blur'},
{type: 'string', min: 1, max: 50, message: '必须1-50个字符', trigger: 'blur'}
],
groupName: [
{type: 'string', min: 1, max: 50, message: '必须1-50个字符', trigger: 'blur'}
],
triggerName: [
{type: 'string', min: 1, max: 50, message: '必须1-50个字符', trigger: 'blur'}
],
triggerGroup: [
{type: 'string', min: 1, max: 50, message: '必须1-50个字符', trigger: 'blur'}
],
description: [
{type: 'string', min: 1, max: 500, message: '必须1-500个字符', trigger: 'blur'}
],

                }
            }
        },
        computed: {},
        mounted() {},
        methods: {
            changeModalVisibleResetForm(formRef, visible) {
                if (!visible) {
                    this.$refs[formRef].resetFields()
                }
            },
            resetFormCancelModal(formRef, modal) {
                this.modal[modal] = false
                this.$refs[formRef].resetFields()
            },
            add() {
                this.$emit('add')
            },
            edit() {
                this.$emit('edit')
            }
        }
    }
</script>

<style>
</style>
